#include "tan_nbmethod.h"
#include "tan_nbobject.h"
#include "tan_stringobject.h"

TanObject* number_toString(TanObject* oneself, TanObject* args, TanObject* attr)
{
	if (!attr)
	{
		if (args && args->object_set->type_next == 0)
		{
			if (strcmp(args->object_type, "number") == 0)
			{
				TAN_INT64 radix = Tan_Number_cast(args)->number;
				TAN_INT8 buffer[65] = { 0 };
				_i64toa(Tan_Number_cast(oneself)->number, buffer, (TAN_INT32)radix);
				return Tan_String_fromString(buffer);
			}
		}
		else
		{
			Tan_RepError(false, "Variable function of type 'number' only supports 1 parameter.", oneself);
		}
	}
	else
	{

	}
	return Tan_String_fromString(0);
}
